package com.dhecp.project.flowable.domain;

import com.dhecp.common.utils.StringUtils;
import com.dhecp.core.constant.FlowableConstant;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * @ClassName ActHistoricTask
 * @Description TODO
 * @Author alula
 * @Date 2019-11-29 15:10
 */
public class ActHistoricTask implements Serializable {

	private static final long serialVersionUID = 3099550323905729586L;
	private String id;    //ACT任务ID
    private String name;  //ACT任务名称
    private String key;   //ACT任务KEY
    private String description;  //ACT任务描述
    private String executionId;  //ACT执行实例ID
    private String procDefId;   //ACT流程定义ID
    private String procDefKey;  //ACT流程定义KEY
    private String procDefName; //ACT流程定义名称
    private Integer procDefVersion; //流程定义版本
    private String procInstId; //ACT流程实例ID
    private String organizer;   //发起人
    private String organizerName; //发起人姓名
    private String corpNo;   //所属公司NO
    private String corpName; //所属公司名称
    private String owner;   //委托人
    private String ownerName; //委托人姓名
    private String assignee;  //受理人
    private String assigneeName;  //受理人姓名
    private Integer priority;
    private Integer suspendState;   //暂停状态
    private String businessKey;   //自定义流程任务主键
    private String tableDataId;   //业务数据表ID
    private String routeUrl;     //业务功能地址
    private String routeName;   //业务功能名称
    private String processTitle;    //流程标题
    private String processRemark;//流程备注
    private String actComment;  //环节意见

    private String deleteReason; //删除原因
    private String comment;    //ACT审批意见
    private Long duration;     //ACT耗时
    private Long workTime;    //ACT工作时间
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date startTime;    //ACT任务开始时间

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date endTime;    //ACT任务结束时间

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date claimTime;   //ACT任务提醒时间

    private String resultStatusName;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getExecutionId() {
        return executionId;
    }

    public void setExecutionId(String executionId) {
        this.executionId = executionId;
    }

    public String getProcDefId() {
        return procDefId;
    }

    public void setProcDefId(String procDefId) {
        this.procDefId = procDefId;
    }

    public String getProcDefKey() {
        return procDefKey;
    }

    public void setProcDefKey(String procDefKey) {
        this.procDefKey = procDefKey;
    }

    public String getProcDefName() {
        return procDefName;
    }

    public void setProcDefName(String procDefName) {
        this.procDefName = procDefName;
    }

    public Integer getProcDefVersion() {
        return procDefVersion;
    }

    public void setProcDefVersion(Integer procDefVersion) {
        this.procDefVersion = procDefVersion;
    }

    public String getProcInstId() {
        return procInstId;
    }

    public void setProcInstId(String procInstId) {
        this.procInstId = procInstId;
    }

    public String getOrganizer() {
        return organizer;
    }

    public void setOrganizer(String organizer) {
        this.organizer = organizer;
    }

    public String getOrganizerName() {
        return organizerName;
    }

    public void setOrganizerName(String organizerName) {
        this.organizerName = organizerName;
    }

    public String getCorpNo() {
        return corpNo;
    }

    public void setCorpNo(String corpNo) {
        this.corpNo = corpNo;
    }

    public String getCorpName() {
        return corpName;
    }

    public void setCorpName(String corpName) {
        this.corpName = corpName;
    }

    public String getOwner() {
        return owner;
    }

    public void setOwner(String owner) {
        this.owner = owner;
    }

    public String getOwnerName() {
        return ownerName;
    }

    public void setOwnerName(String ownerName) {
        this.ownerName = ownerName;
    }

    public String getAssignee() {
        return assignee;
    }

    public void setAssignee(String assignee) {
        this.assignee = assignee;
    }

    public String getAssigneeName() {
        return assigneeName;
    }

    public void setAssigneeName(String assigneeName) {
        this.assigneeName = assigneeName;
    }

    public Integer getPriority() {
        return priority;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    public Integer getSuspendState() {
        return suspendState;
    }

    public void setSuspendState(Integer suspendState) {
        this.suspendState = suspendState;
    }

    public String getBusinessKey() {
        return businessKey;
    }

    public void setBusinessKey(String businessKey) {
        this.businessKey = businessKey;
    }

    public String getTableDataId() {
        return tableDataId;
    }

    public void setTableDataId(String tableDataId) {
        this.tableDataId = tableDataId;
    }

    public String getRouteUrl() {
        return routeUrl;
    }

    public void setRouteUrl(String routeUrl) {
        this.routeUrl = routeUrl;
    }

    public String getRouteName() {
        return routeName;
    }

    public void setRouteName(String routeName) {
        this.routeName = routeName;
    }

    public String getProcessTitle() {
        return processTitle;
    }

    public void setProcessTitle(String processTitle) {
        this.processTitle = processTitle;
    }

    public String getProcessRemark() {
        return processRemark;
    }

    public void setProcessRemark(String processRemark) {
        this.processRemark = processRemark;
    }

    public String getActComment() {
        return actComment;
    }

    public void setActComment(String actComment) {
        this.actComment = actComment;
    }

    public String getDeleteReason() {
        return deleteReason;
    }

    public void setDeleteReason(String deleteReason) {
        this.deleteReason = deleteReason;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public Long getDuration() {
        return duration;
    }

    public void setDuration(Long duration) {
        this.duration = duration;
    }

    public Long getWorkTime() {
        return this.endTime != null && this.claimTime != null ? this.endTime.getTime() - this.claimTime.getTime() : null;
    }

    public void setWorkTime(Long workTime) {
        this.workTime = workTime;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public Date getClaimTime() {
        return claimTime;
    }

    public void setClaimTime(Date claimTime) {
        this.claimTime = claimTime;
    }

    public String getResultStatusName() {
        return getMyDeleteReason(deleteReason);
    }

    public void setResultStatusName(String resultStatusName) {
        this.resultStatusName = resultStatusName;
    }

    public String getMyDeleteReason(String deleteReason){

        if(StringUtils.isEmpty(deleteReason)){
            return "";
        }
        if(FlowableConstant.PASSED_FLAG.equals(deleteReason)){
            deleteReason = "通过";
        }else if(FlowableConstant.AUTOPASSED_FLAG.equals(deleteReason)){
            deleteReason = "自动通过";
        }else if(FlowableConstant.BACKED_FLAG.equals(deleteReason)){
            deleteReason = "回退";
        }else if(FlowableConstant.REJECTED_FLAG.equals(deleteReason)){
            deleteReason = "驳回";
        }else if(FlowableConstant.ENDED_FLAG.equals(deleteReason)){
            deleteReason = "中止";
        }else if(deleteReason.contains(FlowableConstant.DELETE_PRE)){
            String reason = "";
            if(FlowableConstant.DELETE_PRE.equals(deleteReason)){
                reason = "未填写";
            }else if(deleteReason.length()>8){
                reason = deleteReason.substring(8);
            }
            deleteReason = "删除撤回-原因："+reason;
        }else if(deleteReason.contains(FlowableConstant.CANCEL_PRE)){
            String reason = "";
            if(FlowableConstant.CANCEL_PRE.equals(deleteReason)){
                reason = "未填写";
            }else if(deleteReason.length()>9){
                reason = deleteReason.substring(9);
            }
            deleteReason = "发起人撤回-原因："+reason;
        }else if (this.deleteReason.contains(FlowableConstant.Act_DELETE_PRE)) {
            deleteReason = "流程撤回-原因："+"退/驳回流程时撤回";
        }else{
            deleteReason="已删除-原因："+this.deleteReason;
        }
        return deleteReason;
    }
}
